package com.gmail.bloim.serg.acmbuilder;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;

/**
 * User: Администратор
 * Date: 26.04.13
 * Time: 12:42
 */
public class SimpleBuilder {
    public static void main(String[] args) throws IOException {
        ArrayList<JavaFile> javaFiles = new ArrayList<JavaFile>();
        for (int i = 1; i < args.length; i++) {
            String arg = args[i];
            JavaFile jFile = new JavaFile(arg);
            try {
                jFile.parse();
                javaFiles.add(jFile);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        JavaMerger merger = new JavaMerger();
        String merge = merger.merge(javaFiles);
        File file = new File(args[0]);
        FileUtils.writeStringToFile(file, merge);
    }
}
